package com.neouton.crm.op.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.neouton.common.entity.ActivitiVO;
import com.neouton.crm.entity.SysUserEntity;
import com.neouton.crm.op.entity.SalesOpportunityVO;
import com.neouton.crm.sales.entity.SalesFileRelationVO;
import com.neouton.crm.sales.entity.SalesStageVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

@Mapper
public interface SalesOpportunityMapper {
    int insert(SalesOpportunityVO record);

    IPage<SalesOpportunityVO> queryOpportunity(@Param("page") IPage page, @Param("opportunityVO") SalesOpportunityVO opportunityVO, @Param("userList") List<SysUserEntity> userList);

    IPage<SalesOpportunityVO> queryOpportunityAudit(@Param("page") IPage page, @Param("opportunityVO") SalesOpportunityVO opportunityVO);

    IPage<SalesOpportunityVO> queryOpportunityAuditOne(@Param("page") IPage page, @Param("opportunityVO") SalesOpportunityVO opportunityVO);

    List<SalesOpportunityVO> queryOpportunity(@Param("opportunityVO") SalesOpportunityVO opportunityVO, @Param("userList") List<SysUserEntity> userList);

    IPage<SalesOpportunityVO> queryToDoList(@Param("page") IPage page, @Param("opportunityVO") SalesOpportunityVO opportunityVO, @Param("activitis") List<ActivitiVO> activitis);

    /**
     *
     * @param record
     * @return
     */
    List<SalesOpportunityVO> selectAllOpInfo(@Param("record") SalesOpportunityVO record);

    SalesOpportunityVO selectByPrimaryKey(Integer opportunityId);

    SalesOpportunityVO queryOpportunityByBusinessId(@Param("workId")Integer workId);

    SalesOpportunityVO queryHistoryOpportunityByApprovalId(@Param("workId")Integer workId);

    int updateByPrimaryKeySelective(SalesOpportunityVO record);

    int updateOppByCreate(SalesOpportunityVO record);

    void opportunityUpdateStage(SalesStageVO salesStageVO);

    int logicDelete(SalesOpportunityVO record);

    int logicDeleteAudit(SalesOpportunityVO record);

    int updateDeleteAudit(SalesOpportunityVO record);

    int startAudit(SalesOpportunityVO record);

    int approveStateChange(SalesOpportunityVO record);

    int rejectStateChange(SalesOpportunityVO record);

    List<Map<String,Object>> selectAllOpportunityDocument(Integer opId);

    Integer queryOpportunityHeadByProjectId(Integer opId);

    List<SalesFileRelationVO> selectDocymentsByOppid(Integer opId);

    SalesOpportunityVO queryOpportunityByApprovalId(Integer approvalId);

    SalesOpportunityVO queryOpportunityHistoryByApprovalId(Integer approvalId);

    int transforPrincipal(@Param("userId")Integer userId, @Param("list") List<SalesOpportunityVO> list);

    int transforPrincipalProject(@Param("userId")Integer userId, @Param("list") List<SalesOpportunityVO> list);

    List<SalesOpportunityVO> queryOpportunityByCustomerId(int customerId);

    List<SalesOpportunityVO> queryOpportunityBySupplierId(int supplierId);
}
